package com.scommunity.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.scommunity.admin.vo.RolePermVO;
import com.scommunity.domain.Perm;
import com.scommunity.mapper.PermMapper;
import com.scommunity.service.IPermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermServiceImpl extends ServiceImpl<PermMapper, Perm> implements IPermService {

    @Autowired
    private PermMapper permMapper;

    @Override
    public List<Perm> getAll() {
        return permMapper.selectList(null);
    }

    @Override
    public void update(RolePermVO rolePermVO) {
        if (rolePermVO.getChecked()) {
            permMapper.addPerm(rolePermVO.getRoleId(), rolePermVO.getPermId());
        } else {
            permMapper.delPerm(rolePermVO.getRoleId(), rolePermVO.getPermId());
        }
    }
}
